package com.zhc.dejingapi.job;

import com.zhc.dejingapi.service.upload.IGaogeErpBaseInfoUploadService;
import com.zhc.dejingapi.service.upload.IQingFlowDataDownloadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

@Slf4j
@Configuration
public class QingflowDownDataJob {


    public  static  boolean isRunning=false;
    private final JdbcTemplate mysqlJdbcTemplate;
    //private final IQingAppInfoService qqingAppInfoService;
    private final IGaogeErpBaseInfoUploadService gaogeErpBaseInfoUploadService;
    private final IQingFlowDataDownloadService qingFlowDataDownloadService;

    public QingflowDownDataJob(@Qualifier("mySqlJdbcTemplate")JdbcTemplate mysqlJdbcTemplate1,
                               IGaogeErpBaseInfoUploadService qqingAppInfoService1, IQingFlowDataDownloadService qingFlowDataDownloadService1) {
        this.mysqlJdbcTemplate = mysqlJdbcTemplate1;
        this.gaogeErpBaseInfoUploadService = qqingAppInfoService1;
        this.qingFlowDataDownloadService = qingFlowDataDownloadService1;
    }

    public  void executeJob(){
        if(isRunning){
            log.info("ERPProdClassToQingJob is running");
            try{
                Thread.sleep(1000*60*5);
            }
            catch (Exception e){
                e.printStackTrace();
            }

            return;
        }
        isRunning=true;
        int i=1;
        if(i==10){
            try{

                //qingFlowDataDownloadService.downPRoutingData();
                //qingFlowDataDownloadService.downProductExtenData();
                qingFlowDataDownloadService.downProductPicSop();


            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }

            try{

                //qingFlowDataDownloadService.downPRoutingData();


            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }

            try{


                //qingFlowDataDownloadService.downProductExtenData();


            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }

            try{

                //qingFlowDataDownloadService.downPRoutingData();


            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }

            try{


                //qingFlowDataDownloadService.downMoOrderData();


            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }
        }

        isRunning=false;
    }
}
